//
//  MCDataEngine.m
//  MeiCheng
//
//  Created by zhaojianguo on 14-4-18.
//  Copyright (c) 2014年 zhaojianguo. All rights reserved.
//

#import "MCDataEngine.h"

@implementation MCDataEngine
-(MKNetworkOperation *)getSalesDataWithStartDate:(NSString *)startDate withEndDate:(NSString *)endDate WithCompletionHandler:(SalesResponseBlock)completion errorHandler:(MKNKErrorBlock)errorHandler
{
    self.showError = YES;
    NSString *urlPath = @"festival_data.xml";
    MKNetworkOperation *op = [self operationWithPath:urlPath];
    [op addCompletionHandler:^(MKNetworkOperation *completedOperation) {
        NSString * string =  [completedOperation responseString];
        NSLog(@"%@",string);
        id respJson = [completedOperation responseJSON];
        if ([self checkError:respJson]) {
            return ;
        }
        NSLog(@"resp:%@",respJson);
        @try{
            NSMutableArray * array = [NSMutableArray new];
            for (NSDictionary * dictionary in respJson) {
            }
            completion(array);
        }
        @catch (NSException *exception) {
            KHError *appError = [[KHError alloc] initWithDomain:kHAppErrorDomain code:100 userInfo:nil];
            appError.reason = kHErrorParse;
            errorHandler(appError);
        }
    } errorHandler:^(MKNetworkOperation *completedOperation, NSError *error) {
        NSLog(@"ERROR:%@",error);
        KHError *appError = [[KHError alloc] initWithMKNetworkOperation:completedOperation error:error];
        errorHandler(appError);
        
    }];
    [self enqueueOperation:op];
    return op;
}

/*
 http://tingapi.ting.baidu.com/v1/restserver/ting?from=android&version=2.4.0&method=baidu.ting.artist.getinfo&format=xml&tinguid=1025
 
 */


@end
